checkbutton: support CSS paddings and borders
authorCosimo Cecchi <cosimoc@gnome.org>
Thu, 1 May 2014 23:40:26 +0000 (01:40 +0200)
committerCosimo Cecchi <cosimoc@gnome.org>
Fri, 9 May 2014 18:02:42 +0000 (11:02 -0700)
We need this since we just removed focus-padding.

gtk/gtkcheckbutton.c

index 90255617ae8fb58831b0ab1f848f7065428247f5..cce9591af8462b48f8aa7cde20b1e5bc14c607ce 100644 (file)
@@ -254,6 +254,25 @@ _gtk_check_button_get_props (GtkCheckButton *check_button,
     gtk_widget_style_get (widget, "indicator-spacing", indicator_spacing, NULL);
 }
 
+static void
+get_padding_and_border (GtkWidget *widget,
+                        GtkBorder *border)
+{
+  GtkStyleContext *context;
+  GtkStateFlags state;
+  GtkBorder tmp;
+
+  context = gtk_widget_get_style_context (widget);
+  state = gtk_widget_get_state_flags (widget);
+
+  gtk_style_context_get_padding (context, state, border);
+  gtk_style_context_get_border (context, state, &tmp);
+  border->top += tmp.top;
+  border->right += tmp.right;
+  border->bottom += tmp.bottom;
+  border->left += tmp.left;
+}
+
 static void
 gtk_check_button_get_full_border (GtkCheckButton *check_button,
                                   GtkBorder      *border,
@@ -262,6 +281,7 @@ gtk_check_button_get_full_border (GtkCheckButton *check_button,
   int focus_width, indicator_size, indicator_spacing, indicator_extra, border_width;
   GtkWidget *child;
 
+  get_padding_and_border (GTK_WIDGET (check_button), border);
   border_width = gtk_container_get_border_width (GTK_CONTAINER (check_button));
   gtk_widget_style_get (GTK_WIDGET (check_button),
                         "focus-line-width", &focus_width,
@@ -270,10 +290,10 @@ gtk_check_button_get_full_border (GtkCheckButton *check_button,
                         NULL);
   child = gtk_bin_get_child (GTK_BIN (check_button));
 
-  border->left = border_width + focus_width;
-  border->right = border_width + focus_width;
-  border->top = border_width + focus_width;
-  border->bottom = border_width + focus_width;
+  border->left += border_width + focus_width;
+  border->right += border_width + focus_width;
+  border->top += border_width + focus_width;
+  border->bottom += border_width + focus_width;
 
   indicator_extra = indicator_size + 2 * indicator_spacing;
   if (child && gtk_widget_get_visible (child))